package com.saturn.service

import android.app.Service
import android.content.Intent
import android.os.*
import android.telecom.InCallService
import android.util.Log
import com.saturn.bean.User
import com.saturn.callback.IClientCallBack
import com.saturn.callback.IServerBusiness

/**
 * 上传服务
 *
 * @author zfc on 2022/1/19
 */
class UploadService : Service(){

    private val mServer by lazy {
        ServerBusinessImpl()
    }


    override fun onBind(intent: Intent?): IBinder? {
        Log.e(TAG,"onBind xxxx ")
        return mServer.asBinder()
    }

    companion object{
        const val TAG = "UploadService"
    }

    class ServerBusinessImpl():IServerBusiness.Stub(){

        var mCallBack:IClientCallBack? = null

        override fun register(callBack: IClientCallBack?) {
            callBack?.also {
                this.mCallBack = it
            }
        }

        override fun login(userId: Int, pwd: String?) {
            this.mCallBack?.onCall(User(pwd ?: "xx", userId))
        }
    }

}